package com.manage.api.controller;

import com.manage.common.result.Result;
import com.manage.pojo.entity.LoginBody;
import com.manage.pojo.entity.RegisterBody;
import com.manage.service.AuthService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/auth")
@CrossOrigin
@Tag(name = "登录注册管理", description = "登录注册相关接口") // 分类标签
public class AuthController {

    @Autowired
    private AuthService authService;

    /**
     * 登录
     */
    @PostMapping("/login")
    @Operation(summary = "用户登录")
    public Result login(@RequestBody LoginBody loginBody) {
        log.info(loginBody.toString());
        return authService.login(loginBody);
    }

    /**
     * 注册
     */
    @PostMapping("/register")
    @Operation(summary = "用户注册")
    public Result register(@RequestBody RegisterBody registerBody) {
        return new Result().success(authService.register(registerBody));
    }
}
